home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dynExecuteEmitterCommands.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.2 KB  |  138 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17.  
  18. //
  19. //  Alias|Wavefront Script File
  20. //  MODIFY THIS AT YOUR OWN RISK
  21. //
  22. //  Creation Date:  May, 1997
  23. //  Author:         Carol Levy
  24. //
  25. //  Description:
  26. //      dynExecuteEmitterCommands executes the emitter command, particle
  27. //        command (to create the emission object) and connectDynamic command.
  28. //
  29. //  Input Arguments():
  30. //        int $isCreate -- create or add mode
  31. //        string $emitterCmd -- the emitter command string 
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36.  
  37. //
  38. //  ============== dynExecuteEmitterCommands ==============
  39. //
  40. //  SYNOPSIS
  41. //      Execute the emitter command and connectDynamic command.
  42. //      If executing a "Create"/positional emitter command,  create
  43. //      one emitter, create a particle and connect it to the emitter.
  44. //      If executing an "Add" emitter command, add the emitter to
  45. //      all items in the selection list, create a particle and connect
  46. //      it to the emitters.
  47. //
  48. global proc dynExecuteEmitterCommands(int $isCreate, string $emitterCmd)
  49. {
  50.     string $selected[] = `ls -sl`;
  51.  
  52.     if (!$isCreate && size($selected) == 0)
  53.     {
  54.         warning "Nothing is selected to add an emitter to.";
  55.         return;
  56.     }
  57.  
  58.     string $emitterNames[] = evalEcho($emitterCmd);
  59.     string $shapeToConnect;
  60.  
  61.     // Create the particle to be emitted into.
  62.     //
  63.     string $cmd = "particle";
  64.     string $particleNames[] = evalEcho($cmd);
  65.     $shapeToConnect = $particleNames[0];
  66.  
  67.     // If die on exit was set, set this attribute of the particle shape.
  68.     //
  69.     if (`optionVar -query emitterDieOnExit`)
  70.     {
  71.         setAttr ($particleNames[0]+".dieOnEmissionVolumeExit") 1;
  72.     }
  73.  
  74.     // If "need parent uv" was set, and this is a surface emitter,
  75.     // add the parentU/parentV attributes to the particel shape.
  76.     //
  77.     if ((`optionVar -query emitterNeedParentUV`) &&
  78.         (`optionVar -query emitterTypesOM` == 3))
  79.     {
  80.         // $particleNames[1] holds the shape name
  81.         //
  82.         addAttr -ln parentU -dt doubleArray $particleNames[1];
  83.         addAttr -ln parentU0 -dt doubleArray $particleNames[1];
  84.         addAttr -ln parentV -dt doubleArray $particleNames[1];
  85.         addAttr -ln parentV0 -dt doubleArray $particleNames[1];        
  86.     }
  87.  
  88.     // If creating a positional emitter, connect it to the particle
  89.     // just created.
  90.     //
  91.     if ($isCreate)
  92.     {
  93.         evalEcho connectDynamic -em $emitterNames[0] $shapeToConnect;
  94.     }
  95.     else
  96.     {
  97.         // If adding emitters to geometry, connect them all to the
  98.         // particle just created. Emitter command returns name of
  99.         // owner and actual emitter. We want to use the emitter's name
  100.         // in the connect command, so as to connect only that emitter
  101.         // and not any others it may own.
  102.         //
  103.         string $connectCmd = "connectDynamic ";
  104.         for ($i = 0; $i < size($emitterNames)/2; $i++)
  105.         {
  106.             $connectCmd = $connectCmd + "-em "+$emitterNames[$i*2+1]+" ";
  107.         }
  108.  
  109.         $connectCmd = $connectCmd + $shapeToConnect + "; ";
  110.  
  111.         evalEcho ($connectCmd);
  112.     }
  113.  
  114.     // Make the new emitters selected.
  115.     // The result of the "create emitter" command is
  116.     //       emitter1
  117.     // The result of the add emitter command is
  118.     //        object1 emitter1 object2 emitter2 ... object_n emitter_n
  119.     //
  120.     select -cl;
  121.  
  122.     if ($isCreate)
  123.     {
  124.         for ($i = 0; $i < (size($emitterNames)); $i ++)
  125.         {
  126.             select -add $emitterNames[$i];
  127.         }
  128.     }
  129.     else
  130.     {
  131.         for ($i = 1; $i < (size($emitterNames)); $i += 2)
  132.         {
  133.             select -add $emitterNames[$i];
  134.         }
  135.     }
  136. }
  137.  
  138.